package com.fr.base.file;

import com.fr.base.XMLFileManager;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLReadable;
import com.fr.base.xml.XMLableReader;
import com.fr.report.io.xml.SynchronizedVersion;
import com.fr.report.script.FunctionDef;
import java.util.ArrayList;
import java.util.List;

public class FunctionManager extends XMLFileManager
{
  private List functionDefList = new ArrayList();

  public String fileName()
  {
    return "functions.xml";
  }

  public void addFunctionDef(FunctionDef paramFunctionDef)
  {
    this.functionDefList.add(paramFunctionDef);
  }

  public int getFunctionDefCount()
  {
    return this.functionDefList.size();
  }

  public FunctionDef getFunctionDef(int paramInt)
  {
    return ((FunctionDef)this.functionDefList.get(paramInt));
  }

  public void removeFunctionDef(int paramInt)
  {
    this.functionDefList.remove(paramInt);
  }

  public void clearAllFunctionDef()
  {
    this.functionDefList.clear();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isChildNode())
      if (paramXMLableReader.getTagName().equals("XMLVersion"))
      {
        String str = "";
        if ((str = paramXMLableReader.getElementValue()) != null)
        {
          SynchronizedVersion localSynchronizedVersion = SynchronizedVersion.getSynchronizedVersion(Thread.currentThread());
          localSynchronizedVersion.setXmlVersionByString(str);
        }
      }
      else if (paramXMLableReader.getTagName().equals("FunctionDefList"))
      {
        paramXMLableReader.readXMLObject(new XMLReadable(this)
        {
          private final FunctionManager this$0;

          public void readXML()
          {
            if ("FunctionDef".equals(paramXMLableReader.getTagName()))
            {
              String str;
              FunctionDef localFunctionDef = new FunctionDef();
              FunctionManager.access$000(this.this$0).add(localFunctionDef);
              if ((str = paramXMLableReader.getAttr("name")) != null)
                localFunctionDef.setName(str);
              paramXMLableReader.readXMLObject(new FunctionManager.2(this, localFunctionDef));
            }
          }
        });
      }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("FunctionManager");
    if ((this.functionDefList != null) && (this.functionDefList.size() > 0))
    {
      paramXMLPrintWriter.startTAG("FunctionDefList");
      for (int i = 0; i < this.functionDefList.size(); ++i)
      {
        FunctionDef localFunctionDef = (FunctionDef)this.functionDefList.get(i);
        if (localFunctionDef == null)
          break label120:
        paramXMLPrintWriter.startTAG("FunctionDef").attr("name", localFunctionDef.getName()).startTAG("Class").attr("className", localFunctionDef.getClassName()).end().startTAG("Description").textNode(localFunctionDef.getDescription()).end().end();
      }
      label120: paramXMLPrintWriter.end();
    }
    paramXMLPrintWriter.end();
  }

  static List access$000(FunctionManager paramFunctionManager)
  {
    return paramFunctionManager.functionDefList;
  }
}